package com.zero.youxiao.controller;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.opensymphony.xwork2.inject.Inject;
import com.zero.basic.exception.SmsErrorConstant;
import com.zero.basic.exception.SmsRuntimeException;
import com.zero.basic.exception.SmsStatusCode;
import com.zero.basic.util.Captcha;
import com.zero.basic.util.JsonCreator;
import com.zero.youxiao.dto.MenuDto;
import com.zero.youxiao.service.IndexService;

@Controller("indexController")
@RequestMapping("index")
public class IndexController {

	
	@RequestMapping("/checkCode")
	public void drawCheckCode(HttpServletResponse response, HttpSession session)
			throws IOException {
		response.setContentType("image/jpg");
		int width = 200;
		int height = 30;
		Captcha c = Captcha.getInstance();
		c.set(width, height);
		String checkcode = c.generateCheckcode();
		session.setAttribute("cc", checkcode);
		OutputStream os = response.getOutputStream();
		ImageIO.write(c.generateCheckImg(checkcode), "jpg", os);
	}
	
}
